package com.ss.android.topic.b;

import android.database.DataSetObserver;
import android.view.View;
import android.view.ViewGroup;
import android.widget.BaseAdapter;
import android.widget.ListAdapter;
import java.util.ArrayList;
import java.util.List;

public final class a extends BaseAdapter {
    public final List a;
    private ListAdapter b;
    private List c;

    public a(ListAdapter arg2) {
        this.b = arg2;
        this.c = new ArrayList();
        this.a = new ArrayList();
    }

    private int a() {
        return this.c.size();
    }

    public final void a(View arg2) {
        if(!this.c.contains(arg2)) {
            this.c.add(arg2);
            this.notifyDataSetChanged();
        }
    }

    private int b() {
        return this.a.size();
    }

    public final boolean b(View arg2) {
        boolean v0 = this.c.remove(arg2);
        if(v0) {
            this.notifyDataSetChanged();
        }

        return v0;
    }

    public final int getCount() {
        int v0 = this.b != null ? this.b() + this.a() + this.b.getCount() : this.b() + this.a();
        return v0;
    }

    public final Object getItem(int arg4) {
        Object v0 = null;
        int v1 = this.a();
        if(arg4 >= v1) {
            v1 = arg4 - v1;
            if(this.b != null && v1 < this.b.getCount()) {
                v0 = this.b.getItem(v1);
            }
        }
        return v0;
    }

    public final long getItemId(int arg3) {
        long v0_1;
        int v0 = this.a();
        if(this.b == null || arg3 < v0) {
            v0_1 = -1;
        }
        else {
            v0 = arg3 - v0;
            if(v0 < this.b.getCount()) {
                v0_1 = this.b.getItemId(v0);
            } else {
                v0_1 = -1;
            }
        }
        return v0_1;
    }

    public final int getItemViewType(int arg3) {
        int v0 = this.a();
        if(this.b == null || arg3 < v0) {
            v0 = -1;
        }
        else {
            v0 = arg3 - v0;
            if(v0 < this.b.getCount()) {
                v0 = this.b.getItemViewType(v0);
            }
            else {
                v0 = -1;
            }
        }
        return v0;
    }

    public final View getView(int arg4, View arg5, ViewGroup arg6) {
        Object v0_1;
        int v0 = this.a();
        if(arg4 < v0) {
            v0_1 = this.c.get(arg4);
        } else {
            int v1 = arg4 - v0;
            v0 = 0;
            if(this.b != null) {
                v0 = this.b.getCount();
                if(v1 < v0) {
                    return this.b.getView(v1, arg5, arg6);
                }
            }

            v0_1 = this.a.get(v1 - v0);
        }
        return ((View)v0_1);
    }

    public final int getViewTypeCount() {
        return this.b != null ? this.b.getViewTypeCount() : 1;
    }

    public final boolean hasStableIds() {
        boolean v0 = this.b != null ? this.b.hasStableIds() : false;
        return v0;
    }

    public final boolean isEmpty() {
        return this.b == null || (this.b.isEmpty()) ? true : false;
    }

    public final void registerDataSetObserver(DataSetObserver arg2) {
        super.registerDataSetObserver(arg2);
        if(this.b != null) {
            this.b.registerDataSetObserver(arg2);
        }
    }

    public final void unregisterDataSetObserver(DataSetObserver arg2) {
        super.unregisterDataSetObserver(arg2);
        if(this.b != null) {
            this.b.unregisterDataSetObserver(arg2);
        }
    }
}

